﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CamareTrigger : MonoBehaviour
{
    /*
     * 相机移动时与clidder交互脚本
     */
    public Rigidbody camareRig;
    void Start()
    {
        
    }

    //碰撞开始
    private void OnCollisionEnter(Collision collision)
    {
        Debug.Log(collision.transform.name);
        if (collision.transform.name== "植物绿化地形")
        {
            CameraAroundWithDragMove.upDown_bool = false;
            camareRig.constraints = ~(RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY|RigidbodyConstraints.FreezePositionZ);
        }
    }

    private void OnCollisionExit(Collision collision)
    {
        Debug.Log(collision.transform.name);
        if (collision.transform.name == "植物绿化地形")
        {
            CameraAroundWithDragMove.upDown_bool = true;
            camareRig.constraints = RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY
                | RigidbodyConstraints.FreezeRotationZ;
        }
    }

    private void OnCollisionStay(Collision collision)
    {
        //Debug.Log(collision.transform.name);
       
    }

    private void OnTriggerEnter(Collider other)
    {
        //if (UIDown.instance.第一视角_Tog.isOn)
        //{
        //    Debug.Log("接触开始" + other.name);
        //    UIDown.inOrNot_Action(true,other.name);
        //}
        //Debug.Log("开始接触"+other.transform.name);

    }

    private void OnTriggerStay(Collider other)
    {
        //if (UIDown.instance.第一视角_Tog.isOn)
        //{
        //    Debug.Log("接触开始" + other.name);
        //    UIDown.inOrNot_Action(true,other.name);
        //}
        //Debug.Log(other.transform.name);
    }

    private void OnTriggerExit(Collider other)
    {
        //if (UIDown.instance.第一视角_Tog.isOn)
        //{
        //    UIDown.inOrNot_Action(false, other.name);
        //}
        //Debug.Log("接触结束"+other.transform.name);
    }
}
